
<script lang="ts" setup >
import { ref,reactive, onMounted } from "vue";
import adminAdd from "./adminAdd.vue";
import {getAdminListApi} from "@/api/admin";

const drawer = ref(false);

// 显示添加页面
let showAddBox = () => {
    drawer.value = true;
}

// 隐藏添加页面
let closeDrawer = () => {
    drawer.value = false;
    getAdminList();
}

// 管理员列表
const list = reactive([]);

// 获取管理员列表
function getAdminList(){        
    getAdminListApi()
    .then((res:any)=>{
        if(res.code==="200"){        
        list.splice(0,list.length,...res.data);
        }
    })
}

onMounted(()=>getAdminList())

</script>

<template>
    <div class="about">
        <h1>管理员列表</h1>
        <el-button @click="showAddBox">添加管理员</el-button>
        <admin-add v-model="drawer" @close-drawer="closeDrawer"></admin-add>

        <el-table :data="list" style="width: 100%">
            <el-table-column  label="序号" width="180" >
                <template #default="scope">
                    <span>{{scope.$index+1}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="adminid" label="编号" width="180" />
            <el-table-column prop="adminname" label="姓名" width="180" />           

            <el-table-column label="权限">
                <template #default="scope">
                    <span>{{scope.row.role=="2"?"超级管理员":"管理员"}}</span>
                </template>
            </el-table-column>

            <el-table-column label="操作">
                <template #default="scope">
                    <el-button type="primary" >删除</el-button>
                    <el-button type="primary" >编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<style scoped>

</style>

<!-- 权限：
添加管理员：


管理员的权限：

系统首页：0-0
轮播图管理：0-1
  轮播图列表：0-1-0
  添加轮播图：0-1-1

产品管理： 0-2
   产品列表：0-2-0
   秒杀列表：0-2-1
   推荐列表：0-2-2


   adminname: "yangboxing"
checkedKeys: ["0-0", "0-1", "0-1-0", "0-1-1", "0-2", "0-2-0", "0-2-1", "0-2-2", "0-2-3"]
0: "0-0"
1: "0-1"
2: "0-1-0"
3: "0-1-1"
4: "0-2"
5: "0-2-0"
6: "0-2-1"
7: "0-2-2"
8: "0-2-3"
password: "123"
role: 1

-->